#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QButtonGroup>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    layoutInit();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::layoutInit(void)
{
    //初始化菜单索引按钮
    ui->toolButton_student_info->setCheckable(true);
    ui->toolButton_schedule->setCheckable(true);
    ui->toolButton_finance->setCheckable(true);
    ui->toolButton_honor->setCheckable(true);
    ui->toolButton_system_setting->setCheckable(true);
    QButtonGroup *menuGroup = new QButtonGroup(this);
    menuGroup->addButton(ui->toolButton_student_info, 0);
    menuGroup->addButton(ui->toolButton_schedule, 1);
    menuGroup->addButton(ui->toolButton_finance, 2);
    menuGroup->addButton(ui->toolButton_honor, 3);
    menuGroup->addButton(ui->toolButton_system_setting, 4);
    connect(menuGroup, QOverload<int>::of(&QButtonGroup::idClicked), ui->stackedWidget, &QStackedWidget::setCurrentIndex);
    //设置默认选中第一个按钮
    menuGroup->button(0)->setChecked(true);
}

